package com.example.dong.server.ctl;

import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

/**
 * @Author dongzhihua
 * @Date 2021/8/19 23:44
 */
@RestController
@RequestMapping("api/some")
public class SomethingCtl {

    @GetMapping("say")
    public String say(@RequestHeader(required = false, name = "Authorization") String token) {
        return "hello from spring cloud Authorization=" + token;
    }

    @GetMapping("detail/{id}")
    public String detail(@PathVariable int id) throws InterruptedException {
        Assert.isTrue(id > 0, "参数错误");
        Thread.sleep(id);
        return "Order " + id;
    }

    @GetMapping("fallback")
    public String fallback() {
        throw new RuntimeException("fallback");
    }
}
